package com.xjtu.platform.security.infomanage;


import com.xjtu.platform.common.CommonService;
import com.xjtu.platform.common.CurrentUser;
import com.xjtu.platform.common.Result;
import com.xjtu.platform.common.TokenUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/security/infoManage")
public class InfoManageAPI {

    @Resource
    InfoManageService infoManageService;
    @Resource
    private CommonService commonService;


    @RequestMapping(value = "/deleteInfo",method = RequestMethod.POST)
    Result DeleteInfo(@RequestBody InfoManageDto dto, @RequestHeader("Token") String Token){
        infoManageService.deleteInfo(dto);
        return Result.success();
    }

    @RequestMapping(value = "/changeInfo",method = RequestMethod.POST)
    Result changeInfo(@RequestBody InfoManageDto dto, @RequestHeader("Token") String Token){
        System.out.println(dto.getUser_name());
        infoManageService.changeInfo(dto);
        return Result.success("修改成功");
    }


    @RequestMapping(value = "/getInfo",method = RequestMethod.POST)
    Result getInfo(@RequestBody InfoManageDto dto, @RequestHeader("Token") String Token){
        dto.setRole_id("consultor");
        Map<String,Object> page = infoManageService.getInfo(dto);
        System.out.println(infoManageService.getInfo(dto));
        return Result.success(page);
    }

    @RequestMapping(value = "/insertInfo",method = RequestMethod.POST)
    Result insertInfo(@RequestBody InfoManageDto dto, @RequestHeader("Token") String Token){

        dto.setRole_id("consultor");
        infoManageService.insertInfo(dto);
        return Result.success("插入成功");
    }

}
